package org.csmzxy.class2333;

public class 求最大值 {
        public static int findMax(int[] arr) {
            if (arr == null || arr.length == 0) {
                throw new IllegalArgumentException("数组不能为空或长度为0");
            }
            int max = arr[0];
            for (int num : arr) {
                if (num > max) {
                    max = num;
                }
            }
            return max;
        }

        public static void main(String[] args) {
            int[] arr = {1, 3, 5, 7};
            int result = findMax(arr);
            System.out.println("数组的最大值是: " + result);
        }
    }

